import { defineStore } from "pinia";
import request from '../utils/request.js'
export const useStar = defineStore('star',{
    state:()=>{
       return {
        list:[]
       }
    },
    actions:{
        async initStarList(){
            let res = await request.get('/star')
            console.log(res);
            this.list = res.data.data
        },
        async starPost(payload){
            let res = await request.post('/star',payload)
            console.log(res); 
            if(res.data.code == 1){
                this.list.push(payload)
            }
        }
    },
    getters:{//计算函数对于computed
        filterList(){
           let arr=this.list.filter(item=>{
                return item.age>=30
            })
            return arr
        }
    }
}
)